import { request } from '@/utils/request'

export class Resp {
  code: number = 0
  msg: string = ''
}

export interface LoginRequest {
  studentNo: string
  password: string
}
export interface LoginResponse {
  // studentNo: string
  // practiceType: string
  data: {
    token: string
    studentInfo: {}
  }
}
// 登录
export async function login(data: LoginRequest): Promise<LoginResponse> {
  return request({
    url: '/stuclient/api/studentClient/studentLogin',
    method: 'post',
    data,
  })
}

// 登出
export const logout = (): Promise<void> =>
  request({
    url: '/user/logout',
    method: 'post',
  })

export interface SMSRequest {
  clientNo: string
  templateId: string
}
export interface SMSResponse {
  data: {}
}
// 获取验证码
export async function getSmsCode(data: SMSRequest): Promise<SMSResponse> {
  return request({
    url: '/stuclient/api/studentClient/getSMSCode',
    method: 'post',
    data,
    checkToken: false,
  })
}

export interface ResetPsdRequest {
  studentNo: string
  flowId: string
  templateId: string
  verifyCode: string
  newPassword: string
  confirmPassword: string
}

// 重置密码
export async function resetPsd(data: ResetPsdRequest): Promise<Resp> {
  return request({
    url: '/stuclient/api/studentClient/studentResetPwd',
    method: 'post',
    data,
    checkToken: false,
  })
}
